#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n = 0;
    while (scanf("%d", &n) == 1)
    {
        int sum = (3 * n * n + n) / 2;
        printf("%d", sum);
    }
}